class form {
    constructor({
                    id = '',
                    protocolType = '',
                    idcId = '',
                    houseId = '',
                    createStartTime = '',
                    createEndTime = '',
                    idAction = SearchActionConstant.ACCURATE,
                    idcIdAction = SearchActionConstant.ACCURATE,
                } = {}) {
        this.id = id;
        this.protocolType = protocolType;
        this.idcId = idcId;
        this.houseId = houseId;
        this.createStartTime = createStartTime;
        this.createEndTime = createEndTime;
        this.idAction = idAction;
        this.idcIdAction = idcIdAction;
    }
}

new BasicTableVue({
    data: function () {
        return {
            api: insAccessLogQueryApi,
            columns: [
                new TableColumn({
                    prop: 'id',
                    title: '指令ID',
                }),
                new TableColumn({
                    prop: 'idcId',
                    title: '经营者ID',
                }),
                new TableColumn({
                    prop: 'houseName',
                    title: '机房范围',
                }),
                new TableColumn({
                    prop: 'srcIp',
                    title: '源IP',
                }),
                new TableColumn({
                    prop: 'srcPort',
                    title: '源端口',
                }),
                new TableColumn({
                    prop: 'destIp',
                    title: '目的IP',
                }),
                new TableColumn({
                    prop: 'dstPort',
                    title: '目的端口',
                }),
                new TableColumn({
                    prop: 'url',
                    title: '网址',
                }),
                new TableColumn({
                    prop: 'protocolType',
                    title: '协议类型',
                    formatter: this.protocolTypeFormat,
                }),
                new TableColumn({
                    prop: 'startTime',
                    title: '起始时间',
                    formatter: TableColumn.datetimeFormat,
                }),
                new TableColumn({
                    prop: 'endTime',
                    title: '终止时间',
                    formatter: TableColumn.datetimeFormat,
                }),
                new TableColumn({
                    prop: 'reportStatus',
                    title: '上报状态',
                    formatter: TableColumn.reportStatusFormat,
                }),
                new TableColumn({
                    prop: 'timeStamp',
                    title: '生成时间',
                    formatter: TableColumn.datetimeFormat,
                }),
                new TableColumn({
                    prop: 'operating',
                    title: '操作',
                    formatter: this.operationFormat,
                }),
            ],
            houses: [],
            protocolTypes:{
                1:"TCP",
                2:"UDP",
            },


        }
    },
    methods: {
        createForm() {
            return new form();
        },
        operationFormat(row, column, value, index) {
            var result = '';
            switch (row.reportStatus) {
                case 1:
                    result = '执行中';
                    break;
                case 2:
                    result = '执行成功';
                    break;
                case 3:
                    result = '执行异常';
                    break;
                default:
                    result = '未执行';
                    break;
            }
            return result;
        },
        protocolTypeFormat(row, column, value, _index) {
            var result = '';
            value = parseInt(value);
            switch (value) {
                case 1:
                    result = 'TCP';
                    break;
                case 2:
                    result = 'UDP';
                    break;
            }
            return result;
        },
        init() {
            this.initHousesData();
        },
        async initHousesData() {
            this.houses = await baseHouseInfoApi.selectList();
        },
        timeArrayChange(array) {
            [start, end] = array || [];
            this.form.createStartTime = start;
            this.form.createEndTime = end;
        },
    },
    watch: {},
})
